﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using External.APICalling;
using BusinessRule.DTO;
using System.Configuration;
using System.Xml;
using MES.DataGateway.DBUtility;
using System.Data;
using log4net;
using System.Data.OracleClient;
using System.Text;

namespace MESWebService
{
    public class QmsToMesDataMethod
    {
        #region 系统质量问题审理结果--更新
        /// <summary>
        /// 系统质量问题审理结果--更新
        /// </summary>
        /// <returns></returns>
        public Boolean updateQualityHistoryRecord(Dictionary<string,string> para){
            Boolean result = false;
            try
            {
                string strSql = "UPDATE QualityHistoryRecord SET QMSRESULT='{0}',QMSRESULTNOTES='{1}' WHERE DEALNAME='{2}' AND MFGORDERNAME='{3}'";
                string ExcSql = string.Format(strSql, para["hearResult"], para["remark"], para["dealName"], para["orderNo"]);
                int count = OracleHelper.ExecuteSql(ExcSql);
                if (count > 0)
                {
                    result = true;
                }
            }catch(Exception ex){
                result = false;
            }
            return result;
        }
        #endregion

        #region 首件鉴定目录，质量评审目录--插入
        public Boolean InsertFirstIdentifyProduct(Dictionary<string, string> para)
        {
            Boolean result = false;
            try
            {
                string strSql = @"INSERT INTO FirstIdentifyProduct(FIRSTIDENTIFYPRODUCTID, IDENTIFYTYPE, PRODUCTNAME, STATUS, KEYIMPTFILELOGO, VERSIONNO,qprdLevel, BUILDUNIT, REMARK, DRAWINGNO)
                                VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}')";
                string ExcSql = string.Format(strSql, para["firstThingAuthDirId"], para["IdentifyType"], para["componentsName"], "0", para["keyImptFileLogo"], para["VersionNo"],para["Level"],para["BuildUnit"],para["remark"],para["componentsNo"]);
                int count = OracleHelper.ExecuteSql(ExcSql);
                if (count > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                result = false;
            }
            return result;
        }    

        #endregion

        #region 首件鉴定,质量评审控制点解除--更新
        public Boolean UpdateFirstIdentifyProduct(Dictionary<string, string> para) {
            Boolean result = false;
            try
            {
                string strSql = "UPDATE FirstIdentifyProduct SET STATUS='1' WHERE FIRSTIDENTIFYPRODUCTID='{0}' AND IDENTIFYTYPE='{1}'";
                string ExcSql = string.Format(strSql, para["FirstIdentifyProductID"], para["IdentifyType"]);
                int count = OracleHelper.ExecuteSql(ExcSql);
                if (count > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                result = false;
            }
            return result;
        }

        #endregion
    
    }
}